<?php
declare (strict_types=1);

namespace app\api\controller;

use app\common\tool\Result;
use think\Response;
use app\common\model\Version as VersionModel;

class Version extends Base
{
    public function index(): Response
    {
        $android = VersionModel::where(['type'=>1, 'is_new'=>1, 'is_del'=>0])->find();
        $ios = VersionModel::where(['type'=>2, 'is_new'=>1, 'is_del'=>0])->find();

        //暂时隐藏
        /*$version = [
            'android' => [
                'version_no' => $android ? $android->version_no : '',
                'content' => $android ? $android->content : '',
                'down_url' => $android ? $android->down_url : '',
            ],
            'ios' => [
                'version_no' => $ios ? $ios->version_no : '',
                'content' => $ios ? $ios->content : '',
                'down_url' => $ios ? $ios->down_url : '',
            ],
        ];*/

        $version = [
            'android_no' => $android ? $android->version_no : '',
            'androiddownurl' => $android ? $android->down_url : '',
            'ios_no' => $ios ? $ios->version_no : '',
            'iosdownurl' => $ios ? $ios->down_url : '',
            'content' => $android ? $android->content : ''
        ];
        $result = ['code'=>1, 'msg'=>'success', 'data'=>$version];
        return Result::fastReturn($result);
    }
}
